package cn.piggy.quartz.task;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.PersistJobDataAfterExecution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

@Component
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class JobTask extends QuartzJobBean {
    private final Logger logger = LoggerFactory.getLogger(JobTask.class);
    @Override
    protected void executeInternal(@NonNull JobExecutionContext context) {
        try {
            logger.info("TimeEventJob start ..." + LocalDateTime.now());
//            TimeUnit.SECONDS.sleep(8);
            logger.info("TimeEventJob end ..." + LocalDateTime.now());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

